package com.yc.streaming.common;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by jarry on 16/11/14.
 */
public class AppConfig {
    private static Properties props = new Properties();

    static {
        InputStream in = null;
        try {
            in = new FileInputStream("app.properties");
        } catch (FileNotFoundException e) {
            in = AppConfig.class.getClassLoader().getResourceAsStream("app.properties");
        } finally {
            try {
                if(in != null) {
                    props.load(in);
                } else {
                    throw new RuntimeException("can not find app.properties in word dir or classpath");
                }

            } catch (Exception e) {
                throw new RuntimeException("can not find app.propertis in word dir or classpath");
            }
        }
    }

    public static String get(String key) {
        return props.getProperty(key);
    }
}
